<%--
  Created by IntelliJ IDEA.
  User: 大帅
  Date: 2025/7/17
  Time: 17:54
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <link rel="stylesheet" href="/app/Pages/css/all.min.css">
    <title>登录</title>
    <link rel="stylesheet" href="/app/Pages/css/b.css">
</head>
<body>
<div class="login-container">
    <div class="login-header">
        <img src="https://img.tuxiangyan.com/zb_users/upload/2023/02/202302091675904134814455.jpg" alt="Logo" class="logo">
        <h1>欢迎登录</h1>
        <p class="login-tip">你还没有登录请先登录</p>
    </div>

    <div class="login-form">
        <div class="form-group">
            <input type="text" id="yh" placeholder="用户名" class="form-input">
            <i class="icon-user"></i>
        </div>

        <div class="form-group">
            <input type="password" id="mm" placeholder="密码" class="form-input">
            <i class="icon-lock"></i>
        </div>

        <div class="form-options">
            <label class="remember-me">
                <input type="checkbox"> 记住我
            </label>
            <a href="#" class="forgot-password">忘记密码?</a>
        </div>

        <button class="login-btn" onclick="dl()">登 录</button>

        <div class="social-login">
            <span>其他登录方式</span>
        </div>

        <div class="register-link">
            还没有账号? <a href="/register">立即注册</a>
        </div>
    </div>

    <div id="res" class="result-message"></div>
</div>
</body>
<script>
    function dl() {
        var zh = document.getElementById("yh").value
        var mm = document.getElementById("mm").value
        const headers = new Headers();
        const options = {
            method: 'GET',
            headers: headers
        };
        fetch("http://localhost:8080/app/login?name=" + zh + "&pass=" + mm, options)
            .then(response => response.json())
            .then(result => {
                document.getElementById("res").innerHTML = result.msg;
                if (result.code == 200) {
                    setTimeout(() => {
                        location.href = "/app/api/testpost?page=1"
                    }, 1000)
                }
            })
            .catch(error => console.log('error', error));
    }
</script>
</html>
